#include "interface.h"

using namespace sc::error;

Error::Error()
{
	Init();
}

void Error::Init()
{
	if (m_mapError.empty())
	{
		m_mapError[RNG_NOT_LOADED]           = _("Config file (RNG) not loaded");
		m_mapError[SHEMA_INVALID]            = _("Schema invalide");
		m_mapError[XPATH_CTX_INVALID]        = _("XPath expression invalid");
		m_mapError[XPATH_INVALID_EXPRESSION] = _("XPath expression invalid");
		m_mapError[XPATH_NO_RESULT]          = _("No XPath results");
		m_mapError[CHILD_INVALID]            = _("Invalid child");
		m_mapError[ELEMENT_DOESNT_EXIST]     = _("Element doesn't exists");
		m_mapError[CANT_SAVE_FILE]           = _("Can't save file");
		m_mapError[CANT_OPEN_FILE]           = _("Can't open file");
		m_mapError[SCC_NOT_LOADED]           = _("Context file not loaded");
		m_mapError[CONTEXT_DONT_HAVE_SETUP]  = _("Context doesn't have setup");
		m_mapError[XSL_CANT_TRANSFORM]       = _("Can't make transformation");
		m_mapError[UNKNOWN]                  = _("Unknown error");
	}
}

wxString Error::GetString(int e) const
{
	wxString sError = m_mapError.find(UNKNOWN)->second;
	std::map<int, wxString>::const_iterator itError = m_mapError.find(e);
	if (itError != m_mapError.end())
	{
		sError = itError->second;
	}
	return sError;
}
